package com.hitechbangla.fctu.base.aircraft;

import com.hitechbangla.fctu.base.Location;
import com.hitechbangla.fctu.base.LocationInteger;
import com.hitechbangla.fctu.utility.enumall.AircraftIdentity;
import com.hitechbangla.fctu.utility.enumall.ModeIdentity;
import java.awt.Color;
import java.awt.Graphics;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
 *
 * @author deb kanti
 */
public class AircraftState implements Serializable
{
    private String callSign; // it is the id
    private Location location;
    private float heading;
    private float speed; // this speed is not constant, it changes with the command
    private float fuelStatus;    
    private List<Location> listLocation;
    private LocationInteger[] pathDefault;
    private AircraftIdentity aircraftIdentity;
    private ModeIdentity modeIdentity;
    
    public int defaultPathSize()
    {
	int size = 0;
	
	for(int i=0;i<pathDefault.length;i++)
	{
	    if(!pathDefault[i].isNull())
	    {
		size++;
	    }
	    else
	    {
		break;
	    }
	}
	
	return size;
    }
    
    public AircraftState()
    {
        this.location = new Location(0,0,0);
	listLocation = new ArrayList<>();
	
	pathDefault = new LocationInteger[4];
    }
    
    public void addLocationInDefaultPath(LocationInteger locationInteger)
    {
	pathDefault[3] = pathDefault[2];
	pathDefault[2] = pathDefault[1];
	pathDefault[1] = pathDefault[0];
	pathDefault[0] = locationInteger;
    }
    
    public void drawPathDefault(Graphics g, Color color)
    {
	g.setColor(color);
	
	int rectangle = 8;	
	drawPointInLocationInDefaultPath(pathDefault[0], g, rectangle);
	
	rectangle = 6;	
	drawPointInLocationInDefaultPath(pathDefault[1], g, rectangle);
	
	rectangle = 4;	
	drawPointInLocationInDefaultPath(pathDefault[2], g, rectangle);
	
	rectangle = 2;	
	drawPointInLocationInDefaultPath(pathDefault[3], g, rectangle);
    }
    
    private void drawPointInLocationInDefaultPath(LocationInteger locationInteger, Graphics g, int rectangleSize)
    {
	if(locationInteger!=null)
	{
	    g.drawRect(locationInteger.getX() - rectangleSize/2, locationInteger.getY() - rectangleSize/2, rectangleSize, rectangleSize);
	}
    }
    
    
    
    public AircraftState(String callSign, Location location, float heading, float speed, float fuelStatus)
    {
        this.callSign = callSign;
        this.location = location;
        this.heading = heading;
        this.speed = speed;
        this.fuelStatus = fuelStatus;
	listLocation = new ArrayList<>();
    }
    
    
    /**
     * @return the callSign
     * 
     * 
     * 
     */
    
    
    
    public String getCallSign() {
        return callSign;
    }

    /**
     * @param callSign the callSign to set
     */
    public void setCallSign(String callSign) 
    {
        this.callSign = callSign;
    }

    
    /**
     * @return the location
     */
    public Location getLocation() 
    {
        return location;
    }

    /**
     * @param location the location to set
     */
    public void setLocation(Location location) 
    {
        this.location = location;
    }

    /**
     * @return the heading
     */
    public float getHeading() 
    {
        return heading;
    }

    /**
     * @param heading the heading to set
     */
    public void setHeading(float heading) {
        this.heading = heading;
    }

    /**
     * @return the speed
     */
    public float getSpeed() {
        return speed;
    }

    /**
     * @param speed the speed to set
     */
    public void setSpeed(float speed) 
    {
        this.speed = speed;
    }

    /**
     * @return the fuelStatus
     */
    public float getFuelStatus() 
    {
        return fuelStatus;
    }

    /**
     * @param fuelStatus the fuelStatus to set
     */
    public void setFuelStatus(float fuelStatus) 
    {
        this.fuelStatus = fuelStatus;
    }  

    /**
     * @return the listLocation
     */
    public List<Location> getListLocation() {
	return listLocation;
    }

    /**
     * @param listLocation the listLocation to set
     */
    public void setListLocation(List<Location> listLocation) {
	this.listLocation = listLocation;
    }
    public AircraftIdentity getAircraftIdentity() {
        return aircraftIdentity;
    }

    /**
     * @param aircraftIdentity the aircraftIdentity to set
     */
    public void setAircraftIdentity(AircraftIdentity aircraftIdentity) {
        this.aircraftIdentity = aircraftIdentity;
    }
    
     public ModeIdentity getModeIdentity() {
        return modeIdentity;
    }

    /**
     * @param aircraftIdentity the aircraftIdentity to set
     */
    public void setModeIdentity(ModeIdentity modeIdentity) {
        this.modeIdentity = modeIdentity;
    }
}
